package strategy.improve;

import lombok.Setter;

@Setter
public abstract class Duck {
    //其它属性<->策略接口
    protected QuackBehavior quackBehavior;
    private String name;

    //属性, 策略接口
    protected FlyBehavior flyBehavior;
    public Duck(String name) {
        this.name = name;
    }

    public void quack() {
        if (quackBehavior != null) {
            quackBehavior.quack(name);
        }
    }

    public void fly() {
        if (flyBehavior != null) {
            flyBehavior.fly(name);
        }
    }

    public void swim() {
        System.out.println("鸭子会游泳~~");
    }
}
